/**
 * Created by Administrator on 2018/6/26.
 */
/*筛选*/
$(".search").click(function () {
    var data = $("#searchform").serialize();
    window.location.href = '/admin/Message/systemIndex?' + data;
});
/**删除***/
$("#info_delete").click(function () {
    var act = $(this).attr('id');
    var value = new Array();
    $("tbody span[class='checked'] input").each(function (a, b) {
        value[a] = 'id=' + $(this).val();
    });
    var ids = value.join('&');
    var confirm_msg = "确认删除通知吗";
    if(ids==''){
        dshow('请选择至少一条数据进行操作');
        return false;
    }
    if (confirm(confirm_msg)) {
        $.ajax({
            url: '/admin/Message/systemDel',
            type: 'POST',
            data: {ids: ids, act: act},
            dataType: 'JSON',
            cache: false,
            success: function (json) {
                dshow(json.message);
                if (json.code == 2000) {
                    var page = $("input[name='page']").val();
                    window.location.href = '/admin/Message/systemIndex?page=' + page;
                }
            }
        });
    }
});
/*查看详情*/
$('.details').click(function(){
    var n_id = $(this).attr('data-id');
    var page = $("input[name='page']").val();
    window.location.href = '/admin/Message/systemDetails?n_id=' + n_id + '&page=' + page;
})
/*修改消息*/
$('.update').click(function(){
    var n_id = $(this).attr('data-id');
    var page = $("input[name='page']").val();
    window.location.href = '/admin/Message/systemUpdate?n_id=' + n_id + '&page=' + page;
})
/*手动推送*/
$('.red').click(function(){
    var n_id = $(this).attr('data-id');
    var n_title = $(this).attr('data-title');
    $.ajax({
        url:'/admin/Message/systemPublish',
        type:'POST',
        data:{n_id: n_id, n_title: n_title},
        dataType:'json',
        success:function (res) {
            res = JSON.parse(res)
            if(res.code == 200){
                dshow('推送成功');
            }else{
                dshow('推送失败');
            }
        }
    })
})
